package com.glodon.paas.monitor.server.biz.service.impl;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorSendRulesEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorSendRulesMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorSendRulesService;
import com.glodon.paas.monitor.server.dto.MonitorSendRulesDTO;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorSendRulesService")
public class MonitorSendRulesServiceImpl implements MonitorSendRulesService {

	@Autowired
	private MonitorSendRulesMapper	monitorSendRulesMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey sendRules id is null!");
		}
		return monitorSendRulesMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorSendRulesEntity record) {
		if (null == record || null == record.getSendTime()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert sendRules record is null!");
		}
		return monitorSendRulesMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorSendRulesEntity record) {
		if (null == record || null == record.getSendTime()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert sendRules record is null!");
		}
		return monitorSendRulesMapper.insertSelective(record);
	}

	@Override
	public MonitorSendRulesEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey sendRules id is null!");
		}
		return monitorSendRulesMapper.selectByPrimaryKey(id);
	}

	public ArrayList<MonitorSendRulesEntity> queryMonitorSend(MonitorSendRulesDTO monitorSendRulesDTO) {

		return monitorSendRulesMapper.queryMonitorSend(monitorSendRulesDTO);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorSendRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective sendRules record is null!");
		}
		return monitorSendRulesMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorSendRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey sendRules record is null!");
		}
		return monitorSendRulesMapper.updateByPrimaryKey(record);
	}

	@Override
	public int deleteByAlarmId(Long alarmId) {
		if (null == alarmId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByAlarmId sendRules alarmId is null!");
		}
		return monitorSendRulesMapper.deleteByAlarmId(alarmId);
	}

	@Override
	public int deleteByItemId(Long itemId) {
		if (null == itemId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByAlarmId sendRules alarmId is null!");
		}
		return monitorSendRulesMapper.deleteByItemId(itemId);
	}

}
